surface: Small cleanup
authorMatthias Clasen <mclasen@redhat.com>
Sun, 24 Mar 2019 19:26:55 +0000 (15:26 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 28 May 2019 20:25:14 +0000 (20:25 +0000)
Every surface has an impl now, no need to check.

gdk/gdkinternals.h
gdk/gdksurface.c
gdk/quartz/gdksurface-quartz.c
gdk/win32/gdkgeometry-win32.c
gdk/x11/gdksurface-x11.c

index d4c2c1533bdbfcd5f47af95a4039c17295b80bcf..7e1d8e86e9d80e9ac66515c75e009d67a731b212 100644 (file)
@@ -325,8 +325,7 @@ void _gdk_display_set_surface_under_pointer (GdkDisplay *display,
                                              GdkDevice  *device,
                                              GdkSurface  *surface);
 
-gboolean    _gdk_surface_has_impl (GdkSurface *surface);
-GdkSurface * _gdk_surface_get_impl_surface (GdkSurface *surface);
+GdkSurface * gdk_surface_get_impl_surface (GdkSurface *surface);
 
 void gdk_surface_destroy_notify       (GdkSurface *surface);
 
index bd43f4dc5f6e27a06a75dadeb5f2d7f896898f54..fb92e9e7d0a5e902475a62c1d55a65f8990760be 100644 (file)
@@ -482,30 +482,12 @@ gdk_surface_get_property (GObject    *object,
     }
 }
 
-static GdkSurface *
+GdkSurface *
 gdk_surface_get_impl_surface (GdkSurface *surface)
 {
   return surface->impl_surface;
 }
 
-GdkSurface *
-_gdk_surface_get_impl_surface (GdkSurface *surface)
-{
-  return gdk_surface_get_impl_surface (surface);
-}
-
-static gboolean
-gdk_surface_has_impl (GdkSurface *surface)
-{
-  return surface->impl_surface == surface;
-}
-
-gboolean
-_gdk_surface_has_impl (GdkSurface *surface)
-{
-  return gdk_surface_has_impl (surface);
-}
-
 void
 _gdk_surface_update_size (GdkSurface *surface)
 {
@@ -734,14 +716,7 @@ _gdk_surface_destroy_hierarchy (GdkSurface *surface,
       _gdk_surface_clear_update_area (surface);
 
       impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
-
-      if (gdk_surface_has_impl (surface))
-        impl_class->destroy (surface, recursing_native, foreign_destroy);
-      else
-        {
-          /* hide to make sure we repaint and break grabs */
-          gdk_surface_hide (surface);
-        }
+      impl_class->destroy (surface, recursing_native, foreign_destroy);
 
       surface->state |= GDK_SURFACE_STATE_WITHDRAWN;
       surface->destroyed = TRUE;
@@ -1368,12 +1343,9 @@ _gdk_surface_clear_update_area (GdkSurface *surface)
 void
 gdk_surface_freeze_updates (GdkSurface *surface)
 {
-  GdkSurface *impl_surface;
-
   g_return_if_fail (GDK_IS_SURFACE (surface));
 
-  impl_surface = gdk_surface_get_impl_surface (surface);
-  impl_surface->update_freeze_count++;
+  surface->impl_surface->update_freeze_count++;
 }
 
 /**
@@ -1394,7 +1366,7 @@ gdk_surface_thaw_updates (GdkSurface *surface)
   g_return_if_fail (impl_surface->update_freeze_count > 0);
 
   if (--impl_surface->update_freeze_count == 0)
-    gdk_surface_schedule_update (GDK_SURFACE (impl_surface));
+    gdk_surface_schedule_update (impl_surface);
 }
 
 void
@@ -1639,32 +1611,13 @@ gdk_surface_show_internal (GdkSurface *surface, gboolean raise)
   if (raise)
     gdk_surface_raise_internal (surface);
 
-  if (gdk_surface_has_impl (surface))
-    {
-      if (!was_mapped)
-        gdk_synthesize_surface_state (surface,
-                                     GDK_SURFACE_STATE_WITHDRAWN,
-                                     0);
-    }
-  else
-    {
-      surface->state = 0;
-      g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_STATE]);
-      g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_MAPPED]);
-    }
+  if (!was_mapped)
+    gdk_synthesize_surface_state (surface, GDK_SURFACE_STATE_WITHDRAWN, 0);
 
   did_show = _gdk_surface_update_viewable (surface);
 
-  /* If it was already viewable the backend show op won't be called, call it
-     again to ensure things happen right if the mapped tracking was not right
-     for e.g. a foreign surface.
-     Dunno if this is strictly needed but its what happened pre-csw.
-     Also show if not done by gdk_surface_update_viewable. */
-  if (gdk_surface_has_impl (surface) && (was_viewable || !did_show))
-    {
-      impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
-      impl_class->show (surface, !did_show ? was_mapped : TRUE);
-    }
+  impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
+  impl_class->show (surface, !did_show ? was_mapped : TRUE);
 
   if (!was_mapped)
     {
@@ -1836,20 +1789,8 @@ gdk_surface_hide (GdkSurface *surface)
 
   was_mapped = GDK_SURFACE_IS_MAPPED (surface);
 
-  if (gdk_surface_has_impl (surface))
-    {
-
-      if (GDK_SURFACE_IS_MAPPED (surface))
-        gdk_synthesize_surface_state (surface,
-                                     0,
-                                     GDK_SURFACE_STATE_WITHDRAWN);
-    }
-  else if (was_mapped)
-    {
-      surface->state = GDK_SURFACE_STATE_WITHDRAWN;
-      g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_STATE]);
-      g_object_notify_by_pspec (G_OBJECT (surface), properties[PROP_MAPPED]);
-    }
+  if (GDK_SURFACE_IS_MAPPED (surface))
+    gdk_synthesize_surface_state (surface, 0, GDK_SURFACE_STATE_WITHDRAWN);
 
   if (was_mapped)
     {
@@ -1886,12 +1827,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 
   did_hide = _gdk_surface_update_viewable (surface);
 
-  /* Hide foreign surface as those are not handled by update_viewable. */
-  if (gdk_surface_has_impl (surface) && (!did_hide))
-    {
-      impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
-      impl_class->hide (surface);
-    }
+  impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
+  impl_class->hide (surface);
 }
 
 static void
@@ -2479,11 +2416,8 @@ gdk_surface_input_shape_combine_region (GdkSurface       *surface,
   else
     surface->input_shape = NULL;
 
-  if (gdk_surface_has_impl (surface))
-    {
-      impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
-      impl_class->input_shape_combine_region (surface, surface->input_shape, 0, 0);
-    }
+  impl_class = GDK_SURFACE_IMPL_GET_CLASS (surface->impl);
+  impl_class->input_shape_combine_region (surface, surface->input_shape, 0, 0);
 }
 
 static void
@@ -2826,12 +2760,9 @@ gdk_surface_print (GdkSurface *surface,
            surface->width, surface->height
            );
 
-  if (gdk_surface_has_impl (surface))
-    {
 #ifdef GDK_WINDOWING_X11
-      g_print (" impl(0x%lx)", gdk_x11_surface_get_xid (window));
+  g_print (" impl(0x%lx)", gdk_x11_surface_get_xid (window));
 #endif
-    }
 
   g_print (" %s", surface_types[surface->surface_type]);
 
index a3af7844fe1a5c9c55ed6565edbdecec33ff879b..b955e8c021c93e70cc02ad6d0e1796b3d60aa105 100644 (file)
@@ -1505,11 +1505,8 @@ gdk_surface_quartz_get_root_coords (GdkSurface *window,
 
   while (window != toplevel)
     {
-      if (_gdk_surface_has_impl ((GdkSurface *)window))
-        {
-          tmp_x += window->x;
-          tmp_y += window->y;
-        }
+      tmp_x += window->x;
+      tmp_y += window->y;
 
       window = window->parent;
     }
index f800fa8cc6681a867c6e7c383acb06ff47fa331f..ad17a4a8529f490cbc5482414c2b2211c44113c6 100644 (file)
@@ -130,9 +130,7 @@ _gdk_win32_surface_tmp_unset_bg (GdkSurface *window,
   if (window->input_only || window->destroyed || !GDK_SURFACE_IS_MAPPED (window))
     return;
 
-  if (_gdk_surface_has_impl (window) &&
-      GDK_SURFACE_IS_WIN32 (window))
-    tmp_unset_bg (window);
+  tmp_unset_bg (window);
 
   if (recurse)
     {
@@ -162,11 +160,7 @@ _gdk_win32_surface_tmp_reset_bg (GdkSurface *window,
   if (window->input_only || window->destroyed || !GDK_SURFACE_IS_MAPPED (window))
     return;
 
-  if (_gdk_surface_has_impl (window) &&
-      GDK_SURFACE_IS_WIN32 (window))
-    {
-      tmp_reset_bg (window);
-    }
+  tmp_reset_bg (window);
 
   if (recurse)
     {
index 6f23e9ee48bdf72a0397a1913305dab95d12da00..0da023a09d5deb884b26f57a2317aefe9caf992f 100644 (file)
@@ -4475,13 +4475,6 @@ gdk_x11_get_server_time (GdkSurface *surface)
 XID
 gdk_x11_surface_get_xid (GdkSurface *surface)
 {
-  if (!GDK_SURFACE_IS_X11 (surface) ||
-      !_gdk_surface_has_impl (surface))
-    {
-      g_warning (G_STRLOC " drawable is not a native X11 window");
-      return None;
-    }
-  
   return GDK_SURFACE_IMPL_X11 (surface->impl)->xid;
 }
 
@@ -4512,13 +4505,6 @@ void
 gdk_x11_surface_set_frame_sync_enabled (GdkSurface *surface,
                                        gboolean   frame_sync_enabled)
 {
-  if (!GDK_SURFACE_IS_X11 (surface) ||
-      !_gdk_surface_has_impl (surface))
-    {
-      g_warning (G_STRLOC " drawable is not a native X11 window");
-      return;
-    }
-
   GDK_SURFACE_IMPL_X11 (surface->impl)->frame_sync_enabled = FALSE;
 }